package com.jt.controller;

import com.jt.pojo.User;
import com.jt.service.UserService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;
     @GetMapping("/findAll")
    public List<User> findAll(User user){
       List<User>userList= userService.findAll(user);
       return userList;
     }
     @GetMapping("{name}/{age}/{sex}")
    public String saveUser(User user){
         userService.saveUser(user);
         return "用户新增成功";
     }
     @GetMapping("/deleteUserById")
    public String deleteUserById(User user){
         userService.deleteUserById(user);
         return "用户删除成功";
     }
     @GetMapping("/update/{name}/{age}/{sex}/{id}")
    public String update(User user){
         userService.update(user);
         return "用户修改成功";
     }
     @GetMapping("/findUserById")
    public List<User> findUserById(User user){
        List<User> userList= userService.findUserById(user);
        return userList;
     }
     @GetMapping("/findUserByLike")
    public List<User> findUserByLike( User user){
     List<User> userList= userService.findUserByLike(user);
     return userList;

     }
    @GetMapping("/findUserByIn")
    public List<User> findUserByIn(Integer[] id){
        List<User>userList=userService.findUserByIn(id);
        return userList;

    }
     @GetMapping("/findUserByIn1")
     public List<User> findUserByIn1(Integer minAge,Integer maxAge){
         List<User>userList=userService.findUserByIn1(minAge,maxAge);
         return userList;
     }
}
